﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Manufacturer.ascx.cs" Inherits="ERP.Modules.Manufacturer" %>
 <%-------------------------------%>
<ext:Hidden ID="FormatTypeManufacturer" runat="server" />
<ext:Panel runat="server" Layout="Fit" Border="False" ID="PanelManufacturerMain">
    <Content>
        <%--------------GridManufacturer-----------------%>
        <ext:GridPanel
            ID="grManufacturer"
            Cls="grid-double"
            runat="server"
            EnableColumnMove="true"
            Border="False">
            <%-------------StoreManufacturer-----------------%>
            <Store>
                <ext:Store
                    ID="StoreManufacturer"
                    runat="server"
                    OnReadData="StoreManufacturer_RefreshData"
                    PageSize="20">
                    <Model>
                        <ext:Model ID="ModelManufacturer" runat="server" IDProperty="ID_Manufacturer">
                            <Fields>
                                <ext:ModelField Name="Manufacturer_Alias" Type="String" />
                                <ext:ModelField Name="Manufacturer_Name" Type="String" />
                                <ext:ModelField Name="Manufacturer_Email" Type="String" />
                                <ext:ModelField Name="Manufacturer_Phone" Type="String" />
                                <ext:ModelField Name="Manufacturer_Fax" Type="String" />
                                <ext:ModelField Name="Manufacturer_TaxCode" Type="String" />
                                <ext:ModelField Name="Note" Type="String" />
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:RowNumbererColumn ID="RowNumbererColumnManufacturer" runat="server" Width="30" Align="Center" />
                    <ext:Column runat="server" Text="Mã hãng SX" Width="100" DataIndex="Manufacturer_Alias"></ext:Column>
                    <ext:Column runat="server" Text="Tên hãng SX" Width="100" DataIndex="Manufacturer_Name"></ext:Column>
                    <ext:Column runat="server" Text="Email" Width="100" DataIndex="Manufacturer_Email"></ext:Column>
                    <ext:Column runat="server" Text="Phone" Width="100" DataIndex="Manufacturer_Phone"></ext:Column>
                    <ext:Column runat="server" Text="Fax" Width="100" DataIndex="Manufacturer_Fax"></ext:Column>
                    <ext:Column runat="server" Text="MS Thuế" Width="100" DataIndex="Manufacturer_TaxCode"></ext:Column>
                    <ext:Column runat="server" Text="Ghi chú" Width="150" DataIndex="Note" Flex="1"></ext:Column>
                </Columns>
            </ColumnModel>
            <DirectEvents>
                <ItemDblClick OnEvent="ManufacturerDblClick">
                    <ExtraParams>
                        <ext:Parameter Name="ID_Manufacturer" Value="record.data.ID_Manufacturer" Mode="Raw" />
                    </ExtraParams>
                    <EventMask ShowMask="true" Msg="Đang tải..." />
                </ItemDblClick>
            </DirectEvents>
            <SelectionModel>
                <ext:CheckboxSelectionModel runat="server" Mode="Multi">
                     <Listeners>
                       <SelectionChange Handler="
                            if (selected.length == 0) {
                                #{btnEdit}.disable();
                                #{btnDel}.disable();
                                #{btnExport}.disable();
                            } else {
                                #{btnEdit}.enable();
                                #{btnDel}.enable();
                                #{btnExport}.enable();
                            }" />
                   </Listeners>
                </ext:CheckboxSelectionModel>
            </SelectionModel>
            <DockedItems>
                <ext:Toolbar ID="ToolbarTopMain" runat="server" Dock="Top">
                    <Items>
                        <ext:Button ID="btnAddNew" runat="server" Text="Thêm mới" Icon="ApplicationAdd">
                            <DirectEvents>
                                <Click OnEvent="btnAddNew_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnEdit" runat="server" Text="Sửa" Icon="ApplicationEdit">
                            <DirectEvents>
                                <Click OnEvent="btnEdit_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnDel" runat="server" Text="Xoá" Icon="ApplicationDelete">
                            <DirectEvents>
                                <Click OnEvent="btnDel_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                    <ExtraParams>
                                        <ext:Parameter Name="name" Value="btnDel"></ext:Parameter>
                                    </ExtraParams>
                                    <Confirmation ConfirmRequest="true"
                                        Title="Thông Báo" Message="Bạn có muốn xoá mẫu tin này không ?">
                                    </Confirmation>
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnExport" runat="server" Text="Xuất tập tin" Icon="Printer">
                            <Menu>
                                <ext:Menu ID="MenuMain" runat="server">
                                    <Items>
                                        <ext:MenuItem ID="MenuItemExportXML" runat="server" Text="XML" Icon="PageCode">
                                            <Listeners>
                                                <Click Handler="submitValue(#{grManufacturer}, #{FormatTypeManufacturer}, 'xml');" />
                                            </Listeners>
                                        </ext:MenuItem>
                                    </Items>
                                </ext:Menu>
                            </Menu>
                        </ext:Button>
                    </Items>
                </ext:Toolbar>
                <ext:Toolbar runat="server" Dock="Bottom" AnchorHorizontal="100%">
                    <Items>
                        <ext:TriggerField ID="txtSearch" runat="server" Width="200" EnableKeyEvents="true" MarginSpec="0 8 0 0">
                            <Triggers>
                                <ext:FieldTrigger Icon="Search" />
                            </Triggers>
                            <DirectEvents>
                                <TriggerClick OnEvent="Search_Event"></TriggerClick>
                                <KeyUp OnEvent="Search_Event"></KeyUp>
                                <KeyPress OnEvent="Search_Event"></KeyPress>
                            </DirectEvents>
                        </ext:TriggerField>
                        <ext:PagingToolbar ID="PagingToolbarManufacturer" runat="server" StoreID="StoreManufacturer" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                    </Items>
                </ext:Toolbar>
            </DockedItems>
        </ext:GridPanel>
    </Content>
</ext:Panel>
<ext:Panel runat="server">
    <Content>
        <%-----------WindowsManufacturer-----------------%>
        <ext:Window ID="WindowsManufacturer" runat="server"
            Title="Cập nhật hãng sản xuất"
            DefaultAnchor="100%"
            Width="864px"
            Height="380px"
            Hidden="True"
            AutoScroll="False"
            Maximizable="False"
            Minimizable="False"
            AutoDataBind="True"
            Region="Center"
            Resizable="False"
            Modal="True"
            HideMode="Offsets"
            Border="False"
            Padding="5"
            DefaultButton="btnSavePopUp">
            <Items>
                <ext:Toolbar ID="ToolbarManufacturer" runat="server">
                    <Items>
                        <ext:Button runat="server" Text="Lưu lại" Icon="Disk" ID="btnSavePopUp">
                            <DirectEvents>
                                <Click OnEvent="btnSavePopUp_Click" Before="return #{FormPanelManufacturer}.isValid();">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button runat="server" Text="Huỷ bỏ" Icon="Decline" ID="btnCancelPopUp">
                            <DirectEvents>
                                <Click OnEvent="btnCancelPopUp_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                    </Items>
                </ext:Toolbar>
                <ext:Hidden ID="hdIDManufacturer" runat="server" FieldLabel="ID Bank:" AllowBlank="false" Width="250" Visible="True" Margins="0 20 0 0"></ext:Hidden>
                <ext:FormPanel ID="FormPanelManufacturer" runat="server"
                    BodyPadding="10"
                    Frame="true"
                    DefaultAnchor="100%">
                    <Items>
                        <ext:FieldContainer
                            runat="server"
                            AnchorHorizontal="100%"
                            Layout="HBoxLayout">
                            <Items>
                                <ext:TextField ID="txtManufacturer_Alias" LabelAlign="Top" LabelStyle="font-weight: 500" runat="server" FieldLabel="Mã nhà cung cấp (*)" AllowBlank="False" Width="250" Margins="0 5 0 0" /> 
                                <ext:Button runat="server" Text="" Icon="BulletGet" ID="linkManufacturer" ToolTip="Tải lại mã NCC" Margins="18 5 0 0">
                                    <DirectEvents>
                                        <Click OnEvent="linkManufacturer_Click">
                                            <EventMask ShowMask="true" Msg="Đang tải..." />
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                                <ext:TextField ID="txtManufacturer_Name" LabelAlign="Top" LabelStyle="font-weight: 500" runat="server" FieldLabel="Tên nhà cung cấp (*)" AllowBlank="False" Width="250" Margins="0 5 0 0" />
                                <ext:TextField ID="txtLogo" ReadOnly="True" FieldCls="readonly" LabelAlign="Top" LabelStyle="font-weight: 500" runat="server" FieldLabel="Logo" AllowBlank="True" Width="220" Margins="0 5 0 0" />
                                <ext:Button runat="server" Text="" Icon="DiskUpload" ID="btnAddImg" ToolTip="Tải ảnh" Margins="18 5 0 0">
                                    <Listeners>
                                        <Click Handler="#{WindowFileUploadManufacturer}.show();"></Click>
                                    </Listeners>
                                </ext:Button>
                                <ext:Button runat="server" Text="" Icon="Zoom" ID="btnViewImg" ToolTip="Xem ảnh" Margins="18 5 0 0">
                                    <DirectEvents>
                                        <Click OnEvent="btnViewImg_Click">
                                            <EventMask ShowMask="true" Msg="Đang tải..." />
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                            </Items>
                         </ext:FieldContainer>
                         
                        <ext:FieldContainer
                            runat="server"
                            AnchorHorizontal="100%"
                            Layout="HBoxLayout">
                            <Items>
                                <ext:TextField ID="txtEmail" LabelAlign="Top" LabelStyle="font-weight: 500" runat="server" FieldLabel="Email" AllowBlank="True" Width="250" Margins="0 30 0 0" />
                                <ext:TextField ID="txtPhone" LabelAlign="Top" LabelStyle="font-weight: 500" runat="server" FieldLabel="Phone" AllowBlank="True" Width="250" Margins="0 5 0 0" />
                                <ext:TextField ID="txtFax" LabelAlign="Top" LabelStyle="font-weight: 500" runat="server" FieldLabel="Fax" AllowBlank="True" Width="250" Margins="0 5 0 0" />
                            </Items>
                          </ext:FieldContainer>
                        
                        <ext:FieldContainer
                            runat="server"
                            AnchorHorizontal="100%"
                            Layout="HBoxLayout">
                            <Items>
                                <ext:TextField ID="txtWebsite" LabelAlign="Top" LabelStyle="font-weight: 500" runat="server" FieldLabel="Website" AllowBlank="True" Width="250" Margins="0 30 0 0" />
                                <ext:TextField ID="txtAccountNumber" LabelAlign="Top" LabelStyle="font-weight: 500" runat="server" FieldLabel="Phone" AllowBlank="True" Width="250" Margins="0 5 0 0" />
                                <ext:SelectBox
                                    ID="SelectBoxBankManufacturer"
                                    runat="server"
                                    Cls="x-select-box"
                                    LabelAlign="Top"
                                    LabelStyle="font-weight: 500"
                                    FieldLabel="Ngân hàng"
                                    AllowBlank="True"
                                    DisplayField="Bank_Name"
                                    ValueField="Bank_Id"
                                    MarginSpec="0 5 0 0"
                                    Width="250"
                                    ContextMenuID="slBankManufacturerBankContext"
                                    EmptyText="Chọn ngân hàng">
                                    <Store>
                                        <ext:Store ID="StoreBankManufacturer" runat="server" AutoLoad="true" OnReadData="ReloadSelectBox">
                                            <Model>
                                                <ext:Model runat="server">
                                                    <Fields>
                                                        <ext:ModelField Name="Bank_Name" />
                                                        <ext:ModelField Name="Bank_Id" />
                                                    </Fields>
                                                </ext:Model>
                                            </Model>
                                        </ext:Store>
                                    </Store>
                                </ext:SelectBox>
                                <ext:Button runat="server" Text="" Icon="Add" ToolTip="Thêm mới ngân hàng" Margins="18 5 0 0">
                                    <Listeners>
                                        <Click Handler="#{WindowsBank}.show();"></Click>
                                    </Listeners>
                                </ext:Button>
                            </Items>
                        </ext:FieldContainer>
                          
                        <ext:FieldContainer
                                runat="server"
                                AnchorHorizontal="100%"
                                Layout="HBoxLayout">
                                <Items>
                                    <ext:TextField ID="txtTaxCode" LabelAlign="Top" LabelStyle="font-weight: 500" runat="server" FieldLabel="Mã số thuế" AllowBlank="True" Width="250" Margins="0 30 0 0" />
                                    <ext:DateField ID="txtDateCreate" EmptyText="Vui lòng chọn ngày" AllowBlank="True" LabelAlign="Top" LabelStyle="font-weight: 500" runat="server" FieldLabel="Ngày thành lập:"  Width="250" Margins="0 5 0 0"/>
                                    <ext:TextField ID="txtAddress" LabelAlign="Top" LabelStyle="font-weight: 500" runat="server" FieldLabel="Địa chỉ (*)" AllowBlank="False" Width="250" Margins="0 5 0 0" />
                                </Items>
                          </ext:FieldContainer>
                       <ext:TextArea ID="txtDescription" LabelAlign="Top" LabelStyle="font-weight: 500" runat="server" FieldLabel="Ghi chú" AnchorHorizontal="100%" Height="100" AllowBlank="True" FieldStyle="text-align:left;" />
                    </Items>
                </ext:FormPanel>
            </Items>
        </ext:Window>
        <ext:Menu runat="server" ID="slBankManufacturerBankContext">
            <Items>
                <ext:Button runat="server" Text="Tải lại" Icon="DatabaseRefresh" Flat="True">
                    <Listeners>
                        <Click Handler="#{SelectBoxBankManufacturer}.clearValue(); #{StoreBankManufacturer}.reload(); #{slBankManufacturerBankContext}.hide();"></Click>
                    </Listeners>
                </ext:Button>
            </Items>
        </ext:Menu>
        <%--------------FileUpload-----------------%>
        <ext:Window 
            ID="WindowFileUploadManufacturer" 
            runat="server" 
            Closable="True"
            Resizable="False"
            Height="150" 
            Icon="DiskUpload" 
            Title="Tải tập tin"
            Draggable="False"
            Hidden="True"
            Width="350"
            Modal="True"
            Border="False"
            BodyPadding="5"
            HideMode="Offsets"
            Layout="FormLayout">
            <Items>
                <ext:FormPanel 
                    ID="BasicForm" 
                    runat="server"
                    Frame="True"
                    MarginSpec="0 8 0 0"
                    AutoHeight="true">
                    <Items>
                        <ext:FileUploadField 
                            ID="FileUploadPanel" 
                            runat="server" 
                            EmptyText="Chọn tập tin"
                            MarginSpec="0 8 0 0"
                            ButtonText=""
                            Width="300"
                            Icon="Attach">
                        </ext:FileUploadField>
                    </Items>
                </ext:FormPanel>
            </Items>
            <Buttons>
                <ext:Button ID="btnUpload" runat="server" Text="Tải lên" Icon="DiskUpload">
                    <DirectEvents>
                        <Click 
                            OnEvent="btnUpload_Click"
                            Before="if (!#{BasicForm}.getForm().isValid()) { return false; } 
                                Ext.Msg.wait('Đang tải tập tin...', 'Đang tải');"
                                
                            Failure="Ext.Msg.show({ 
                                title   : 'Lỗi', 
                                msg     : 'Có lỗi xảy ra trong quá trình tải lên.Hoặc dung lượng tập tin quá lớn', 
                                minWidth: 200, 
                                modal   : true, 
                                icon    : Ext.Msg.ERROR, 
                                buttons : Ext.Msg.OK 
                            });">
                        </Click>
                    </DirectEvents>
                </ext:Button>
                <ext:Button ID="btnCancel" runat="server" Text="Bỏ qua" Icon="Decline">
                    <DirectEvents>
                        <Click OnEvent="btnCancel_Click">
                            <EventMask ShowMask="true" Msg="Đang tải..." />
                        </Click>
                    </DirectEvents>
                </ext:Button>
            </Buttons>
        </ext:Window>
        <%--------------ViewImages-----------------%>
        <ext:Window 
            ID="WindowViewImages" 
            runat="server" 
            Title="Xem ảnh"
            Icon="Map"
            Width="800"
            Height="498"
            Resizable="False"
            Modal="True"
            AutoScroll="True"
            Hidden="True"
            Region="Center"
            HideMode="Offsets"
            Border="False"
            DefaultAnchor="100%">
            <Items>
                 <ext:Image ID="ImageLogo" runat="server">
                     <ResizableConfig runat="server" PreserveRatio="true" HandlesSummary="s e se"/>
                 </ext:Image>
             </Items>
         </ext:Window>
    </Content>
</ext:Panel>